package de.hauschild.gmltracer.gml.impl.value.geometry.tier1;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;
import de.hauschild.gmltracer.gml.impl.value.geometry.ShapeToken;
import de.hauschild.gmltracer.tracer.Shape;

public class UnionOperatorToken extends AbstractToken {

  @SuppressWarnings("unchecked")
  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final ShapeToken<? extends Shape> second = tokenStack.pop(ShapeToken.class);
    final ShapeToken<? extends Shape> first = tokenStack.pop(ShapeToken.class);

    tokenStack.push(new UnionToken(first, second));
  }

  @Override
  public String toString() {
    return "union";
  }
}
